package com.jshan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jshan.base.entity.SysServer;
import com.jshan.mapper.SysServerMapper;
import com.jshan.service.SysServerService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
@RequiredArgsConstructor
public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer> implements SysServerService {
    private final SysServerMapper serverMapper;

    @Override
    public List<SysServer> listAll() {
        return list();
    }

    @Override
    public IPage<SysServer> getServerPage(IPage<SysServer> page, String serverName) {
        LambdaQueryWrapper<SysServer> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(serverName != null, SysServer::getName, serverName);
        return page(page, wrapper);
    }

    @Override
    public boolean saveServer(SysServer server) {
        return save(server);
    }

    @Override
    public boolean updateServer(SysServer server) {
        return updateById(server);
    }

    @Override
    public boolean deleteServer(Long id) {
        return removeById(id);
    }
}
